import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class TagWidget extends StatelessWidget {
  final String title;
  final Color color;
  final Color backgroundColor;
  const TagWidget.copyWith(this.title,
      {super.key,
      this.color = Colors.black,
      this.backgroundColor = Colors.grey});
  factory TagWidget(String title) {
    switch (title) {
      case '近地铁':
        return TagWidget.copyWith(title,
            color: Colors.white, backgroundColor: Colors.red);
      case '新上':
        return TagWidget.copyWith(title,
            color: Colors.white, backgroundColor: Colors.blue);
      case '随时看房':
        return TagWidget.copyWith(title,
            color: Colors.white, backgroundColor: Colors.green);
      case '集中供暖':
        return TagWidget.copyWith(title,
            color: Colors.white, backgroundColor: Colors.orange);
      default:
        return TagWidget.copyWith(title);
    }
  }
  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(right: 4.w),
      padding: EdgeInsets.only(left: 4.w, right: 4.w),
      decoration: BoxDecoration(
        color: backgroundColor,
        borderRadius: BorderRadius.circular(8.r),
        border: Border.all(color: color, width: 1),
      ),
      child: Text(
        title,
        style: TextStyle(
          fontSize: 10.sp,
          color: color,
        ),
      ),
    );
  }
}
